import { Editor } from './Editor'
import './style.scss'

const editor = new Editor(document.getElementById('container') as HTMLDivElement)

document
    .getElementById('toolbar')
    ?.querySelectorAll('.btn')
    .forEach(a =>
        a.addEventListener('click', e => {
            const btn = e.target as HTMLButtonElement
            const method = btn.dataset.formatMethod!
            const param = btn.dataset.formatParam!
            if (method === 'b') {
                editor.formatBlock(param as any)
            } else {
                editor.formatInline(param as any)
            }
        }),
    )
